package com.ky.pro.java.dt.kitchen.controller;


import com.ky.pro.java.dt.common.web.ResultBean;
import com.ky.pro.java.dt.kitchen.entity.KitchenProcess;
import com.ky.pro.java.dt.kitchen.service.impl.KitchenProcessServiceImpl;
import com.sun.istack.internal.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Kevin Dummy
 * @since 2021-12-26
 */
@RestController
@RequestMapping("/kitchen")
public class KitchenProcessController {

    @Autowired
    KitchenProcessServiceImpl kitchenProcessService;

    @PutMapping("/orderNo/{orderNo}/status/{status}")
    public ResultBean<String> updateKitchenProcessStatus(@PathVariable("orderNo") @NotNull Long orderNo,
                                                         @PathVariable("status") @NotNull Integer status) {
        return kitchenProcessService.updateKitchenProcessStatus(orderNo, status);
    }

    @PostMapping("/")
    public ResultBean<String> createKitchenProcess(@RequestBody KitchenProcess kitchenProcess) {
        return kitchenProcessService.save(kitchenProcess) ? ResultBean.genResult("创建成功") : ResultBean.genResult("创建失败");
    }

    @GetMapping("/existence/orderNo/{orderNo}")
    public ResultBean<Boolean> checkExistence(@PathVariable("orderNo") Long orderNo) {
        return kitchenProcessService.checkKitchenProcessExistence(orderNo);
    }

}

